import java.util.*;

public class Index {

	private Map<String, LinkedList<Resource>> indexMap;
	private LinkedList<Resource> resList;
	
	public Index() {
		indexMap = new HashMap<String, LinkedList<Resource>>();
	}
	
	public void add(Resource res) {
		for(String str : res.getType().getCollector().getKeywords(res)) {
			if(indexMap.containsKey(str)) {
				indexMap.get(str).add(res);
			}
			else {
				resList = new LinkedList<Resource>();
				resList.add(res);
				indexMap.put(str, resList);
			}
		}
	}
	
	public List<Resource> getResources(String keyword) {
		return indexMap.get(keyword);
	}
	
}
